# Copyright (C) 
# 2024 ZKLX Optoelectronic Technology Co.LTD
# All rights reserved.
#
# @file CMakeLists.txt
# @brief build for run_test
# @author EExuke
# @version 1.0
# @date 2024-04-25


cmake_minimum_required(VERSION 3.10)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "-fopenmp")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")

# Target Name
project(run_test C CXX)

# 默认为Release
if (NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE Release)
endif ()
message("Build type: ${CMAKE_BUILD_TYPE}")

#OpenCV Package
find_package(OpenCV REQUIRED)
message(STATUS "OpenCV library status:")
message(STATUS "version:${OpenCV_VERSION}")
message(STATUS "libraries:${OpenCV_LIBS}")
message(STATUS "include path:${OpenCV_INCLUDE_DIRS}")
include_directories(${OpenCV_INCLUDE_DIRS})

# Includes
include_directories(${PROJECT_SOURCE_DIR}/inc)
include_directories(${PROJECT_SOURCE_DIR}/../Crow_src/Asio/include)
include_directories(${PROJECT_SOURCE_DIR}/Middlewares/my_cJSON/include)

# Lib dirs
link_directories(${PROJECT_SOURCE_DIR}/Middlewares/my_cJSON)

# Src files
aux_source_directory(${PROJECT_SOURCE_DIR}/src SOURCES_LIST)
add_executable(${PROJECT_NAME} ${SOURCES_LIST})

# Link
target_link_libraries(${PROJECT_NAME} -lrt -lpthread)
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS})
target_link_libraries(${PROJECT_NAME} -lcjson)

# strip
if(DEFINED ENV{STRIP})
	set(CMAKE_STRIP $ENV{STRIP})
else()
	set(CMAKE_STRIP "strip")
endif()
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
	COMMAND ${CMAKE_STRIP} "$<TARGET_FILE:${PROJECT_NAME}>"
	COMMENT "Strip(${CMAKE_STRIP}) debug symbols done on final binary.")

